//
//  TiaoBianViewController.m
//  SensorTagEX
//
//  Created by sno on 15-2-1.
//  Copyright (c) 2015年 Texas Instruments. All rights reserved.
//

#import "TiaoBianViewController.h"
#import "CmdData.h"
#import "BLEUtility.h"

@interface TiaoBianViewController ()

@property (weak, nonatomic) IBOutlet UISlider *mSlider;
@property (weak, nonatomic) IBOutlet UILabel *mlabTime;

@end

@implementation TiaoBianViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
  
    _isOpen=NO;
    _second=1;
    _mSlider.maximumValue=255;
    _mSlider.minimumValue=1;
}
-(void)viewDidAppear:(BOOL)animated
{

}
-(void)viewDidDisappear:(BOOL)animated
{

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)tiaobianSwitch:(UISwitch *)sender {
    _isOpen=sender.isOn;
    NSData *data=[CmdData getTiaoBianArray:_isOpen second:_second];
    [BLEUtility writeData:data];
}
- (IBAction)valueChanged:(UISlider *)sender {
   if(_isOpen)
    {
        int no = (int)(sender.value + 0.5);
        _second=no;
        float fsec=(float)no;
        
        NSString *str=[NSString stringWithFormat:@"%.1f秒",fsec/2];
        _mlabTime.text=str;
    }
}
- (IBAction)btnSendData:(UIButton *)sender {
    NSData *data=[CmdData getTiaoBianArray:_isOpen second:_second];
    [BLEUtility writeData:data];
}

@end
